export function useDownExcel() {
  function handleRes(res: any) {
    const url = window.URL.createObjectURL(new Blob([res.data]));
    const link = document.createElement('a');
    link.href = url;
    link.setAttribute('download', 'data.xlsx');
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  }
  async function downExamExcel() {
    await getExamExcel().then((res: any) => {
      handleRes(res);
    });
  }
  async function downWorkingHoursExcel() {
    await getWorkHoursExcel().then((res) => {
      handleRes(res);
    });
  }
  async function downDetailsExcel() {
    await getEngineerExcel().then((res) => {
      handleRes(res);
    });
  }
  return {
    downExamExcel,
    downWorkingHoursExcel,
    downDetailsExcel,
  };
}
